# Maintainer: David Macek <david.macek.0@gmail.com>

_realname="msys2-launcher"
pkgname=("${_realname}-git")
pkgver=0.3.32.56c2ba7
pkgrel=2
pkgdesc="Helper for launching MSYS2 shells"
arch=('x86_64' 'i686')
license=('MIT')
groups=('base')
backup=({mingw32,mingw64,msys2}.ini)
provides=("${_realname}")
conflicts=("${_realname}")
depends=("mintty>=1~2.2.1")
makedepends=('mingw-w64-cross-gcc')
source=("git+https://github.com/elieux/msys2-launcher")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  local _major=$(cat version.h | grep -F 'VER_MAJOR' | head -1 | sed -e 's/.* //')
  local _minor=$(cat version.h | grep -F 'VER_MINOR' | head -1 | sed -e 's/.* //')
  printf "%s.%s.%s.%s" "${_major}" "${_minor}"  "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "${srcdir}/${_realname}"
  make PREFIX=/opt/bin/${CARCH}-w64-mingw32-
}

package() {
  cd "${srcdir}/${_realname}"
  cp {mingw32,mingw64,msys2}.{exe,ini} "${pkgdir}"
}
